

<div class="section">
  <div class="section-title">Báo Cáo Tình Hình Nhận Báo</div>
    <?php 
    if($_GET['print'] !="true" )
    { 
    ?> 
 	 <div class="right">
    <a class="button print" id="btnPrint">In</a>
    <a class="button exit" href="?route=deliman/home">Đóng</a>
    </div>
    <?php }?>
  <div>
  	<?php 
    if($_GET['print'] !="true" )
    { 
    ?>
      <form>
        <table>
          <thead>
            <tr>
              <td style="text-align:right;"><label>Khu vực:</label></td>
              <td>
              
              <select name="qlkhuvuc" id="qlkhuvuc">
              <option value="0">-----Chọn tất cả-----</option>
                  <?php foreach($khuvucs as $khuvucdangphutrach){ ?>
                  <option value="<?php echo $khuvucdangphutrach['khuvucid']?>">
                  	<?php echo $this->string->getPrefix("&nbsp; &nbsp; &nbsp; &nbsp;",$khuvucdangphutrach['level']);?>
                  	<?php echo $khuvucdangphutrach['tenkhuvuc']?>
                  </option>
                  <?php }?>
                </select>
                
                <a class="button-other search"  style="margin-bottom: -29px;" id="btntim"></a>
                </td>
             
            </tr>
            
          </thead>
        </table>
      </form>
      <?php }?>
      <form action="" method="post" name="postlist" id="postlist">
      <table width="100%" class="data-table">
        <thead>
        		<th>Tên khách hàng</th>
                <th>Điện thoại</th>
                <th>Địa chỉ</th>
                <th>Ngày đặt gần nhất</th>
                <th>Tổng số lượng đặt</th>
                <th>Tổng số lượng đã giao</th>
                <th>Ngày giao gần nhất</th>
                <th>Kỳ giao gần nhất</th>
                <th>Nhân viên giao</th>
        </thead>
        <tbody>
     	<?php 
        	foreach($phutrachkhuvuc as $item)
        		{
                if(count($item['data_khachhang']))
                {
		        	$flag=0;
        ?>
       
       
            	<tr id="<?php echo 'kv'.$item['khuvucid'] ?>">
                	<td style="background:#CCCCCC" colspan="9">
                        <?php echo $item['tenkhuvuc']?>
                    </td>
                </tr>
           
           
            <?php
				
             ?>
            	<?php foreach($item['data_khachhang'] as  $khachhang)
              	 		 {
                         $soluongdat=(int)$khachhang['soluongdat'];
                        
                         if($soluongdat>0)
                         	{
                 ?>
                    <tr>
                    	<td><?php echo $khachhang['hoten'] ?></td>
                        <td><?php echo $khachhang['dienthoai'] ?></td>
                        <td><?php echo $khachhang['diachi'] ?></td>
                        <td><?php echo $this->date->formatMySQLDate($khachhang['ngaydat'])?></td>
                        <td><?php echo $this->string->numberFormate($khachhang['soluongdat']) ?></td>
                        <td><?php echo $this->string->numberFormate($khachhang['soluonggiao'] )?></td>
                        <td><?php echo $this->date->formatMySQLDate($khachhang['ngaygiao'],'longdate')?></td>
                        <td><?php echo $khachhang['kygiao'] ?></td>
                        <td><?php echo $khachhang['nhanvien'] ?></td>
                        
                     </tr>   
                <?php 
                		$flag=1;
               				}
                      	 }
                       if($flag==0)
                       {
                ?>
                <script language="javascript">
                        $temp = "<?php echo '#kv'.$item['khuvucid'] ?>";
                        $(""+$temp).hide();
				</script>	
      	<?php 
					   }
        		}
        		
       		 }
        
         ?>
           </tbody>
        </table>
      
      
     
      </form>
    </div>
</div>
<script language="javascript">
		$(document).ready(function(){
			
			$('#btntim').click(function(){
				window.location="?route=deliman/baocaotinhhinhnhanbao&khuvucid="+$('#qlkhuvuc').val();
			});
			$('#qlkhuvuc').val("<?php echo $_GET['khuvucid'];?>");
			$('#btnPrint').click(function(){
			
			var url = window.location+"&print=true";
			 var result = window.showModalDialog(url,"", "dialogWidth:1000px; dialogHeight:800px; center:yes");
			});	
		});

</script>
<?php if($_GET['print'] =="true" ){ ?>
<script language="javascript">
        window.print();
    </script>
<?php } ?>